/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.ServicesSet;
import model.entities.Services;
import model.entities.Room;



/**
 *
 * @author Hieu.Nguyen
 */
public class ServicesSetDAO {
    private static ServicesSetDAO datDichVuDAO;

    public static ServicesSetDAO getInstance1() {
        if (datDichVuDAO == null) {
            datDichVuDAO = new ServicesSetDAO();
        }
        return datDichVuDAO;
    }
    
     public List<ServicesSet> getServicesSet(boolean isActived) {
        List<ServicesSet> listServicesSet = new ArrayList<ServicesSet>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblServicesSet";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                ServicesSet r = new ServicesSet();
                
                r.setServicesSetID(rs.getInt("ServicesSetID"));
                
                Room r1 = RoomDAO.getInstance().getRoomByID(rs.getInt("RoomID"));
                r.setRoom(r1);
                
                Services d1 = ServicesDAO.getInstance().getServicesByID(rs.getInt("ServicesID"));
                r.setServices(d1);
                
                r.setDateSetSV(rs.getDate("DateSetSV"));
                
                r.setTimeSetSV(rs.getString("TimeSetSV"));
                
                r.setNumberServices(rs.getInt("NumberServices"));
                
                r.setAmountSum(rs.getFloat("AmountSum"));
                listServicesSet.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listServicesSet;
    }
}
